<cfsilent>
<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: comments.cfm 947 2006-08-24 01:14:46Z mpwoodward $

Notes:
--->
<cfset comments = event.getArg("comments") />
<cfset comment = event.getArg("comment") />
<cfset commentOutput = false />
</cfsilent>
<cfoutput>
<cfif event.isArgDefined("message")>
	<p style="font-weight:bold;color:##ff0000;">#event.getArg("message")#</p>
</cfif>

<!--- don't show all the comments if this is an edit --->
<cfif comment.getCommentId() EQ "">
	<table border="0" cellpadding="2" cellspacing="1" width="500" class="content">
		<tr>
			<td><h2>#getProperty("resourceBundleService").getResourceBundle().getResource("comments")#</h2></td>
		</tr>
		<cfif comments.RecordCount GT 0>
			<cfloop query="comments">
				<cfif is_active>
					<tr>
 						<td style="border-bottom:1px solid ##dedede;padding-bottom:8px;">
							<!--- the comment text is stripped of HTML and line breaks are formatted into p tags, so no need for a br 
									between the comment and the posted by info --->
							#comment#
							<strong>
								#getProperty("resourceBundleService").getResourceBundle().getResource("postedby")# 
								<cfif url NEQ ""><a href="#url#" target="_blank" rel="nofollow">#name#</a><cfelse>#name#</cfif> @ 
								#getProperty("resourceBundleService").getLocaleUtils().i18nDateFormat(dt_created, 3)# 
								#getProperty("resourceBundleService").getLocaleUtils().i18nTimeFormat(dt_created, 3)#
							</strong>
						</td>
					</tr>
					<cfset commentOutput = true />
				</cfif>
			</cfloop>

			<cfif Not commentOutput>
				<tr>
					<td>
						<em>
							<strong>
								#getProperty("resourceBundleService").getResourceBundle().getResource("nocomments")#
							</strong>
						</em>
					</td>
				</tr>
			</cfif>

			<cfelse>
				<tr>
					<td>
						<em>
							<strong>
								#getProperty("resourceBundleService").getResourceBundle().getResource("nocomments")#
							</strong>
						</em>
					</td>
				</tr>
		</cfif>
	</table>
</cfif>

<form name="commentForm" action="index.cfm?#getProperty('eventParameter')#=processCommentForm&amp;entryId=#event.getArg('entryId')#" 
		method="post">
	<table border="0" cellpadding="2" cellspacing="1" width="500">
		<tr>
			<td colspan="2">
				<h3>
					<cfif comment.getCommentId() EQ "">
						#getProperty("resourceBundleService").getResourceBundle().getResource("addyourcomments")#
					<cfelse>
						#getProperty("resourceBundleService").getResourceBundle().getResource("updatecomment")#
					</cfif>
				</h3>
			</td>
		</tr>
		<cfif getProperty("moderateComments")>
			<tr bgcolor="##dedede">
				<td colspan="2">
					#getProperty("resourceBundleService").getResourceBundle().getResource("commentmoderationonmessage")#
				</td>
			</tr>
		</cfif>
		<tr>
			<td align="right">* #getProperty("resourceBundleService").getResourceBundle().getResource("name")#</td>
			<td>
				<input type="text" name="name" size="30" maxlength="100" 
						value="#comment.getName()#" />
			</td>
		</tr>
		<tr>
			<td align="right">#getProperty("resourceBundleService").getResourceBundle().getResource("email")#</td>
			<td>
				<input type="text" name="email" size="30" maxlength="100" 
						value="#comment.getEmail()#" />
			</td>
		</tr>
		<tr>
			<td align="right">#getProperty("resourceBundleService").getResourceBundle().getResource("url")#</td>
			<td>
				<input type="text" name="url" size="30" maxlength="250" 
						value="#comment.getUrl()#" />
			</td>
		</tr>
		<cfif getProperty("allowCommentSubscriptions")>
			<tr>
				<td align="right">#getProperty("resourceBundleService").getResourceBundle().getResource("subscribe")#</td>
				<td>
					<input type="checkbox" name="isSubscribed" value="1"
							<cfif comment.getIsSubscribed()> checked</cfif> />
				</td>
			</tr>
		</cfif>
		<tr>
			<td align="right" valign="top">* #getProperty("resourceBundleService").getResourceBundle().getResource("comments")#</td>
			<td valign="top">
				<textarea name="comment" cols="30" rows="6">#comment.getComment()#</textarea>
			</td>
		</tr>
		<cfif getProperty("useCaptcha")>
		<tr>
			<td>&nbsp;</td>
			<td valign="top">
				#event.getArg("layout.captchaSnip")#
			</td>
		</tr>
		</cfif>
		<cfif comment.getCommentId() NEQ "">
			<tr>
				<td align="right">#getProperty("resourceBundleService").getResourceBundle().getResource("active")#</td>
				<td>
					<input type="checkbox" name="isActive" value="1"
							<cfif comment.getAudit().getIsActive()> checked</cfif> />
				</td>
			</tr>
		</cfif>
		<tr>
			<td>&nbsp;</td>
			<td>
				<input type="submit" name="submit" 
						value="<cfif comment.getCommentId() EQ ''>#getProperty('resourceBundleService').getResourceBundle().getResource('submitcomments')#<cfelse>#getProperty('resourceBundleService').getResourceBundle().getResource('updatecomment')#</cfif>" />
			</td>
		</tr>
	</table>
	<input type="hidden" name="subscriberEmailSent" value="#comment.getSubscriberEmailSent()#" />
	<input type="hidden" name="commentId" value="#comment.getCommentId()#" />
</form>

<cfif getProperty("allowCommentSubscriptions")>
<form name="subscriptionForm" action="index.cfm?#getProperty('eventParameter')#=processCommentSubscriptionForm&amp;entryId=#event.getArg('entryId')#" 
		method="post">
	<table border="0" cellpadding="2" cellspacing="1" width="500">
		<tr>
			<td colspan="2">
				<h3>
					#getProperty("resourceBundleService").getResourceBundle().getResource("subscribewithoutcommenting")#
				</h3>
			</td>
		</tr>
		<tr>
			<td align="right">* #getProperty("resourceBundleService").getResourceBundle().getResource("email")#</td>
			<td>
				<input type="text" name="email" size="30" maxlength="100" 
						value="#comment.getEmail()#" />
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>
				<input type="submit" name="subscriptionSubmit" value="#getProperty('resourceBundleService').getResourceBundle().getResource('subscribe')#" />
			</td>
		</tr>
	</table>
</form>
</cfif>

<script type="text/javascript">
	// validate form input
	objForm = new qForm("commentForm");
	
	objForm.name.required = true;
	objForm.name.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('name')#";
	objForm.name.validateNotEmpty();
	
	objForm.email.required = false;
	objForm.email.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('email')#";
	objForm.email.validateNotEmpty();
	objForm.email.validateEmail("#getProperty('resourceBundleService').getResourceBundle().getResource('emailnotvalid')#");
	
	objForm.url.required = false;
	objForm.url.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('url')#";
	objForm.url.validateNotEmpty("#getProperty('resourceBundleService').getResourceBundle().getResource('urlallspaces')#");
	
	objForm.comment.required = true;
	objForm.comment.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('comments')#";
	objForm.comment.validateNotEmpty();
	
	<cfif getProperty("useCaptcha")>
	objForm.captchaValidate.required = true;
	objForm.captchaValidate.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('captchatext')#";
	objForm.captchaValidate.validateNotEmpty();
	</cfif>
	
	objSubscriptionForm = new qForm("subscriptionForm");
	
	objSubscriptionForm.email.required = true;
	objSubscriptionForm.email.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('email')#";
	objSubscriptionForm.email.validateNotEmpty();
	objSubscriptionForm.email.validateEmail("#getProperty('resourceBundleService').getResourceBundle().getResource('emailnotvalid')#");
</script>
</cfoutput>